package com.heo.queue.task;

import java.util.Date;

/**
 * 需要向控制端发起的回调任务
 * 
 * @author chichi
 */
public class CallBackTask
{
  private String httpUrl;// 要发送给设备的数据包
  private String sendContent;// 要发送的内容
  private ReSendInfo reSendInfo = new ReSendInfo();// 重发信息，如果为null，则表示该数据不需要重发

//  public CallBackTask(String httpUrl, String sendContent, int maxReSendCount, long expireTime)
//  {
//    this.httpUrl = httpUrl;
//    this.sendContent = sendContent;
//    reSendInfo.setExpireTime(expireTime);
//    reSendInfo.setMaxReSendCount(maxReSendCount);
//  }
  
  /**
   * 使用配置参数里的超时时间和重发次数
   * @param httpUrl
   * @param sendContent
   * @param maxReSendCount
   */
  public CallBackTask(String httpUrl, String sendContent)
  {
    this.httpUrl = httpUrl;
    this.sendContent = sendContent;
  }

  /**
   * 设置重发
   */
  public void setReSend()
  {
    if (reSendInfo == null)
    {
      return;
    }
    reSendInfo.setLastSendTime(new Date().getTime());
    reSendInfo.setReSendCount(reSendInfo.getReSendCount() + 1);
  }

  public ReSendInfo getReSendInfo()
  {
    return reSendInfo;
  }

  public void setReSendInfo(ReSendInfo reSendInfo)
  {
    this.reSendInfo = reSendInfo;
  }

  public String getHttpUrl()
  {
    return httpUrl;
  }

  public void setHttpUrl(String httpUrl)
  {
    this.httpUrl = httpUrl;
  }

  public String getSendContent()
  {
    return sendContent;
  }

  public void setSendContent(String sendContent)
  {
    this.sendContent = sendContent;
  }

}
